package dipl.algorithm.statistics;

/**
 * Class storing statistical data collected during algorithm
 */
public class Statistics {

	//
	// CONSTRUCTOR METHODS
	//

	/**
	 *
	 */
	public Statistics() {
		InitializeMembers();
	}

	//
	// PUBLIC METHODS
	//

	@Override
	public String toString() {
		String s = "";
		s += "[";
		s += "\nrunning time (in s).........."+((double)(endTimeMS-startTimeMS)/1000.0);
		s += "\nstart precision.............."+startPrecision;
		s += "\nend precision................"+endPrecision;
		s += "\n\n-> Data for first curve:\n";
		s += "\nmax subdivision depth........"+subdivisionDepth_f;
		s += "\nnumber of subdivisions......."+numSubdivisions_f;
		s += "\nnumber of subdivision-nodes.."+numNodes_f;
		s += "\nnumber of checked intervals in subdivision-nodes:";
		s += "\nmin.........................."+minComparedIntervals_f;
		s += "\nmax.........................."+maxComparedIntervals_f;
		s += "\nmean........................."+meanComparedIntervals_f;
		s += "\n\n-> Data for second curve:\n";
		s += "\nmax subdivision depth ......."+subdivisionDepth_g;
		s += "\nnumber of subdivisions......."+numSubdivisions_g;
		s += "\nnumber of subdivision-nodes.."+numNodes_g;
		s += "\nnumber of checked intervals in subdivision-nodes:";
		s += "\nmin.........................."+minComparedIntervals_g;
		s += "\nmax.........................."+maxComparedIntervals_g;
		s += "\nmean........................."+meanComparedIntervals_g;
		s += "\n]";
		return s;
	}

	//
	// AUXILLIARY METHODS
	//

	/**
	 * Initialize members
	 */
	private void InitializeMembers() {
		startTimeMS = 0;
		endTimeMS = 0;
		startPrecision = 0;
		endPrecision = 0;
		subdivisionDepth_f = 0;
		subdivisionDepth_g = 0;
		numSubdivisions_f = 0;
		numSubdivisions_g = 0;
		numNodes_f = 0;
		numNodes_g = 0;
		meanComparedIntervals_f = 0.0;
		meanComparedIntervals_g = 0.0;
		minComparedIntervals_f = 0;
		maxComparedIntervals_f = 0;
		minComparedIntervals_g = 0;
		maxComparedIntervals_g = 0;
	}

	//
	// MEMBERS
	//
	/**
	 * time (in ms) when algorithms starts
	 */
	public long startTimeMS;
	/**
	 * time (in ms) when algorithms ends
	 */
	public long endTimeMS;
	/**
	 * number of bits needed to correctly calculate curve control polygon
	 * at start of algorithm.
	 */
	public int startPrecision;
	/**
	 * number of bits needed to correctly calculate curve control polygon
	 * after termination of algorithm. (updated during algorithm)
	 */
	public int endPrecision;
	/**
	 * Number of subdivisions performed on first curve during algorithm 
	 */
	public int numSubdivisions_f;
	/**
	 * Number of subdivisions performed on second curve during algorithm
	 */
	public int numSubdivisions_g;
	/**
	 * Number of subdivision nodes in tree for first curve
	 */
	public int numNodes_f;
	/**
	 * Number of subdivision nodes in tree for second curve
	 */
	public int numNodes_g;
	/**
	 * Depth of subdivision reached during algorithm for first curve.
	 */
	public int subdivisionDepth_f;
	/**
	 * Depth of subdivision reached during algorithm for second curve.
	 */
	public int subdivisionDepth_g;
	/**
	 * mean of interval count stored in subdivision tree nodes of first curve.
	 * (is determined at the end of algorithm)
	 */
	public double meanComparedIntervals_f;
	/**
	 * minimum number of checked segments in one subdivision node for first curve
	 */
	public int minComparedIntervals_f;
	/**
	 * maximum number of checked segments in one subdivision node for first curve
	 */
	public int maxComparedIntervals_f;
	/**
	 * mean of interval count stored in subdivision tree nodes of second curve.
	 * (is determined at the end of algorithm)
	 */
	public double meanComparedIntervals_g;
	/**
	 * minimum number of checked segments in one subdivision node for second curve
	 */
	public int minComparedIntervals_g;
	/**
	 * maximum number of checked segments in one subdivision node for second curve
	 */
	public int maxComparedIntervals_g;
}
